#include "saveqrcode.h"
#include "ui_saveqrcode.h"
#include<QFileDialog>
#include"qtqrcode.h"
#include<QPixmap>
#include<QImage>

SaveQRCode::SaveQRCode(QStringList sl,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SaveQRCode)
{
    ui->setupUi(this);
    this->strList=sl;
    setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint);
//    sl<<"设备名称：优盘"<<"设备编号：xxxx"<<"资产编号：xxx"<<"使用开始日期:2021-2-21 18:21:10"<<"超期年限：12个月"<<"保养时间：月保养"<<"所属公司：宝德计算机";
    resultImage=QtQrcode().createQRCodeTag(sl);
    pixmap=QPixmap::fromImage(resultImage);
    ui->label_2->setPixmap(pixmap);
}

SaveQRCode::~SaveQRCode()
{
    delete ui;
}

void SaveQRCode::on_pushButton_2_clicked()
{
    this->close();
}

void SaveQRCode::on_pushButton_clicked()
{
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"),this->strList[0],tr("Image file (*.png)"));
    if(!fileName.isEmpty()){
        resultImage.save(fileName);
    }
    this->close();
}
